package com.eaoa.uc.pubmessage.action;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.eaoa.base.EABaseAction;
import com.eaoa.constants.AttachmentConstants;
import com.eaoa.constants.PubMessageConstants;
import com.eaoa.query.pub.PubMessageQuery;
import com.eaoa.uc.pubmessage.bo.MessageModifyBatchBO;
import com.eaoa.utils.AttachmentUtils;
import com.eaoa.vo.pub.PubMessage;
import com.stony.core.util.CoreUtils;

public class MessageReceiveSearchExpandAction extends EABaseAction {

	protected ActionForward doWork(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		Long messageno = CoreUtils.parseLong(request.getParameter("messageno"));
		
		PubMessage message = PubMessageQuery.loadByNo(messageno);
		
		//List<PubMessage> results  = PubMessageQuery.loadBySessionid(message.getSessionid());
		
		message.setStatus(PubMessageConstants.MESSAGE_STATUS_YRD);		
		new MessageModifyBatchBO(message).execute();

		request.setAttribute("message", message);
		//request.setAttribute("results", results);
		
		if(message.getSessionid()!=null){
			Map attachments = AttachmentUtils.getAttachmentMap(AttachmentConstants.ATTACHMENTTYPE_MESSAGE,message.getSessionid());
			request.setAttribute("attachments", attachments);
		}

		return mapping.findForward("success");

	}

}
